import java.util.Scanner;
import java.util.Stack;

public class day230512 {
    // Emacs计算器
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            Stack<Integer> stack = new Stack<>();
            int result = 0;
            for (int i = 0; i < n; i++) {
                String str = sc.next();
                char ch = str.charAt(0);
                if (!(str.equals("+") || str.equals("-") || str.equals("*") || str.equals("/"))) {
                    // 是数字
                    // 不能用 Character.isDigit(ch)
                    // 负数的情况, ch 只会被取到 -
                    stack.push(Integer.parseInt(str));
                } else {
                    // 先取出的是右操作数
                    int right = stack.pop();
                    int left = stack.pop();
                    switch (ch) {
                        case '+':
                            stack.push(left + right);
                            break;
                        case '-':
                            stack.push(left - right);
                            break;
                        case '*':
                            stack.push(left * right);
                            break;
                        case '/':
                            stack.push(left / right);
                    }
                }
            }
            System.out.println(stack.peek());
        }
    }


    // 五子棋
    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            char[][] board = new char[20][20];
            for (int i = 0; i < 20; i++) {
                String s = sc.nextLine();
                for (int j = 0; j < 20; j++) {
                    board[i][j] = s.charAt(j);
                }
            }

            if (isWin(board)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }

    private static boolean isWin(char[][] board) {
        char tmp;
        int k;
        int count;
        for (int i = 0; i < 20; i++) {
            for (int j = 0; j < 20; j++) {

                if (board[i][j] != '.') {
                    // 有落子
                    tmp = board[i][j];

                    if (j <= 15) {
                        // 判断横向, 注意不要越界
                        for (k = 1, count = 1; k < 5; k++) {
                            if (tmp != board[i][j + k]) {
                                break;
                            }
                            count++;
                        }
                        if (5 == count) {
                            return true;
                        }

                        // 判断右下方向
                        if (i <= 15) {
                            for (k = 1, count = 1; k < 5; k++) {
                                if (tmp != board[i + k][j + k]) {
                                    break;
                                }
                                count++;
                            }
                            if (5 == count) {
                                return true;
                            }
                        }

                        // 判断右上方向
                        if (i >= 4) {
                            for (k = 1, count = 1; k < 5; k++) {
                                if (tmp != board[i - k][j + k]) {
                                    break;
                                }
                                count++;
                            }
                            if (5 == count) {
                                return true;
                            }
                        }
                    }

                    // 判断竖向
                    if (i <= 15) {
                        for (k = 1, count = 1; k < 5; k++) {
                            if (tmp != board[i + k][j]) {
                                break;
                            }
                            count++;
                        }
                        if (5 == count) {
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }
}
